<nav class="navbar navbar-expand-lg bg-body-tertiary sticky-top z-2">
  <div class="container-fluid">
    <a class="navbar-brand" href="/">博客</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav me-auto mb-2 mb-lg-0">
        <li class="nav-item">
          <a class="nav-link" href="/">首页</a>
        </li>
        <% if (isSignIn) { %>
        <li class="nav-item">
          <a class="nav-link" href="/write">写博客</a>
        </li>
        <% } %>
      </ul>
      <ul class="navbar-nav mb-2 mb-lg-0">
        <% if (!isSignIn) { %>
        <li class="nav-item">
          <a class="nav-link" href="/sign-in">登录</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="/sign-up">注册</a>
        </li>
        <% } else { %>
        <li class="nav-item">
          <a class="nav-link" href="javascript:;">欢迎：<%= user.username %></a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#" id="sign-out" data-bs-toggle="modal" data-bs-target="#sign-out-modal">退出登录</a>
        </li>
        <% } %>
      </ul>
    </div>
  </div>
</nav>

<script>
  $(function() {
    $('#sign-out').on('click', (e) => {
      e.preventDefault()
    })

    $('#confirmSignOut').on('click', () => {
      window.location.href = '/sign-out'
    })
  })
</script>

<!-- Sign-Out Modal -->
<div class="modal fade" id="sign-out-modal" tabindex="-1">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h1 class="modal-title fs-5" id="exampleModalLabel">温馨提示</h1>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        您确定退出登录吗？
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取 消</button>
        <button type="button" class="btn btn-primary" id="confirmSignOut">确 定</button>
      </div>
    </div>
  </div>
</div>